//=============================================================================

#ifndef AOBJECT_H
  #define AOBJECT_H

//=============================================================================

#include "aVector.h"
#include "aModel.h"
#include "aAction.h"

//=============================================================================

enum drwTypes
{
  DRAW = 1,
  DRAW_TRIANGLES = 2,
  DRAW_LINES = 4,
  DRAW_POINTS = 8,
  DRAW_NORMALS = 16,
  DRAW_SKELETON = 32,
  DRAW_ORIGIN = 64,
  DRAW_JOINTS_AXIS = 128,
};

//=============================================================================

enum aotRet
{
  OBJ_DONE = -128,
  OBJ_BAD_PATH,
  OBJ_CANT_OPEN_OBJECT_FILE,
  OBJ_BAD_MAGIC_IN_OBJECT_FILE,
  OBJ_SURFACE_ABS_BAD_DATA_POINTER,
  OBJ_SURFACE_ABS_BAD_VERTEXES_COUNT,
  OBJ_SKIN_ABS_BAD_DATA_POINTER,
  OBJ_SKIN_ABS_BAD_TEXTURES_COUNT,
  OBJ_SKELETON_ABS_BAD_DATA_POINTER,
  OBJ_SKELETON_ABS_BAD_JOINTS_COUNT,
  OBJ_ANIM_ABS_BAD_DATA_POINTER,
  OBJ_ANIM_ABS_NO_SUCH_JOINT_FOR_ANIM,
};

//=============================================================================

class aObject
{
  public:
    inline void aoDrawObject()                                                    {mainModel.amAnimateModel(); mainModel.asDrawSurface();}
    inline amlRet aoLoadMainModel(const aString& path)                            {return mainModel.amLoadModel(path);}
    inline aseRet aoLoadMainSkin(const aString& path)                             {return mainModel.asLoadSkin(path);}
    inline asnRet aoLoadMainSkeleton(const aString& path)                         {return mainModel.amLoadSkeleton(path, mainModel.asGetVertexesCount());}
    inline amlRet aoLoadModelAnimation(const aString& path, const aString& name)  {return mainModel.amLoadAnimation(path, name);}
    inline amlRet aoPlayAnimation(const aString& name, bool loop)                 {return mainModel.amPlayAnimation(name, loop);}
    inline unsigned long aoGetMainModelVertexesCount()                            {return mainModel.asGetVertexesCount();}
    inline aVector aoGetMainModelBBDiff()const                                    {return mainModel.asGetBBDiff();}
    inline unsigned int aoGetAnimationFramesCount(const aString& name)            {return mainModel.amGetAnimationFramesCount(name);}
    inline bool aoHasAnimation(const aString& name)                               {return mainModel.amHasAnimation(name);}
    inline unsigned int aoPauseAnimation(const aString& name)                     {return mainModel.amPauseAnimation(name);}
    inline void aoSetAnimationFrame(const aString& name, unsigned int frame)      {return mainModel.amSetAnimationFrame(name, frame);}
    inline bool aoIsAnimationPaused(const aString& name)                          {return mainModel.amIsAnimationPaused(name);}
    inline unsigned int aoGetAnimationFrame(const aString& name)                  {return mainModel.amGetAnimationFrame(name);}
    inline void aoGetJointsList(aList<aString>& list)                             {return mainModel.amGetJointsNames(list);}
    inline aseRet aoCollectSurfaceData(void* vuvn, size_t wholeSize)const         {return mainModel.asCollectSurfaceData(vuvn, wholeSize);}
    inline size_t aoGetSurfaceDataVolume()const                                   {return mainModel.asGetSurfaceDataVolume();}
    inline size_t aoGetSkeletonDataVolume()const                                  {return mainModel.amGetSkeletonDataVolume();}
    inline asnRet aoCollectSkeletonData(void* data, size_t wholeSize)const        {return mainModel.amCollectSkeletonData(data, wholeSize);}
    inline int aoGetJointsCount()const                                            {return mainModel.amGetJointsCount();}
    inline size_t aoGetSkinDataVolume()const                                      {return mainModel.asGetSkinDataVolume();}
    inline askRet aoCollectSkinData(void* data, size_t wholeSize)const            {return mainModel.asCollectSkinData(data, wholeSize);}
    inline int aoGetMaterialTexturesCount()const                                  {return mainModel.asGetMaterialTexturesCount();}
    inline size_t aoGetAnimationsDataVolume()const                                {return mainModel.amGetAnimationDataVolume();}
    inline amlRet aoCollectAnimationsData(void* data, size_t wholeSize)const      {return mainModel.amCollectAnimationsData(data, wholeSize);}
    inline int aoGetAnimationsCount()const                                        {return mainModel.hasAnimations.alGetCount();}
    inline void aoClearObjectData()                                               {mainModel.amDestroyModel();}
    inline int aoGetHealth()                                                      {return health;}
    inline int aoGetMana()                                                        {return mana;}
    inline int aoGetStamina()                                                     {return stamina;}
    inline void aoReceiveAction(const aActionChoosed& act)                        {if (!aoFindAction(act.type)) actions.alAddItem()->data.aaPrepareAction(act);}
    inline unsigned long aoGetObjectId()                                          {return id;}

    aObject(unsigned long setId);
      void aoSetDrawProperties(unsigned char params);
      virtual aotRet aoLoadObject(const aString& path);
      void aoGetMainModelAnimationsList(aList<aString>& animList);
      bool aoFindAction(aanAct type);
      virtual void aoObjectProcess() {};
    virtual ~aObject();

  public:
    aString name;
     unsigned long id;
 
  protected:
    aVector position;
    aModel mainModel;
    int health;
    int mana;
    int stamina;
    aList<aAction> actions;
};

//=============================================================================

#endif

//=============================================================================